//
//  ViewNewsController.m
//  wl
//
//  Created by wsl on 16/8/21.
//  Copyright © 2016年 itcast.com. All rights reserved.
//
#import "UIImage+Image.h"
#import "ViewNewsController.h"
#import "TableViewCell.h"
#import "NewsTableViewCell.h"

#import "momoViewController.h"

#import "NoticeViewController.h"


#import "GoodfrienViewController.h"

@interface ViewNewsController ()
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation ViewNewsController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
       
    //设置右边的按钮图片没有渲染
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageWithOriginalName:@"lxr"] style:UIBarButtonItemStyleDone target:self action:@selector(lxr)];
    

    

}
//导航栏右边按钮
-(void)lxr{
//    GoodfriendgroupViewController *good = [[GoodfriendgroupViewController alloc]init];
//    [self.navigationController pushViewController:good animated:YES];
    
    GoodfrienViewController *gooder = [[GoodfrienViewController alloc] init];
    
    [self.navigationController pushViewController:gooder animated:YES];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//返回多少组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    //#warning Incomplete implementation, return the number of sections
    return 2;
}
//返回多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    int i = 2;
    
    if (section == 1) {
        
        i = 5;
    }
    
    
    return i;
}


//cell高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    int i = 50;
    if (indexPath.section == 1) {
        i = 80;
    }
    
    return i;
}

//返回组头的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 10 ;
}
//返回cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    id cells;
    
    
    if (indexPath.section == 0) {
        
        static NSString *deteID = @"TableViewCell";
        TableViewCell *cello = [tableView dequeueReusableCellWithIdentifier:deteID];
        
        if (cello == nil) {
            cello = [[[NSBundle mainBundle] loadNibNamed:deteID owner:nil options:nil] lastObject];
        }
       
        if (indexPath.row == 0) {
            
            cello.imageview.image = [UIImage imageNamed:@"ywxg"];
            cello.labeltitle.text = @"与我相关";
        }else{
             cello.imageview.image = [UIImage imageNamed:@"gztz"];
             cello.labeltitle.text = @"关注通知";
        }
        cells = cello;
        
    }else{
        
        static NSString *ID = @"NewsTableViewCell";
        NewsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
        
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:ID owner:nil options:nil] lastObject];
        }
           cells =  cell ;

    }
    
    
    return cells;
}



#pragma mark 点击cell
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            //与我相关
            momoViewController *rela = [[momoViewController alloc]init];
            
            [self.navigationController pushViewController:rela animated:YES];
            
        }else{
            //关注通知
            NoticeViewController *notic = [[NoticeViewController alloc]init];
            [self.navigationController pushViewController:notic animated:YES];
        }
    }
    
}



@end
